package com.wngbms.feigndemo.impl;

import java.lang.reflect.Proxy;
import java.util.Map;

public class FeignClientBuilder {

    public static <T> T newInstance(Class<T> type) {
        Map<String, MethodMeta> methodMetaMap = MethodHandler.apply(type);
        FeignInvocationHandler feignInvocationHandler = new FeignInvocationHandler(methodMetaMap);

        T proxyInstance = (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, feignInvocationHandler);
        return proxyInstance;
    }

}
